package com.lwc.controller;

import com.lwc.bean.Dept;
import com.lwc.bean.User;
import com.lwc.remote.DeptRemoteClient;
import com.lwc.remote.UserRemoteClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class PurchaseController {

    @Autowired
    UserRemoteClient remoteClient;
@Autowired
    DeptRemoteClient deptRemoteClient;

@GetMapping("/purchase")
    public Map get(int id){
    Map map=new HashMap<>();
    map.put("id",id);
    map.put("name","zahjnn");
//根据采购员id查看采购员信息
    User user=remoteClient.get(id);
map.put("user",user);
        return  map;
    }


    @GetMapping("/purchase2")
   public Map getlist2(){
Map map=new HashMap<>();
map.put("id",23);
List<User>list=remoteClient.getlist(2,3);
map.put("user",list);
return  map;
    }

    @GetMapping("/purchase3")
    public Map getlist3(){
    Map newmap=new HashMap<>();
    newmap.put("id",15);
        Map map=deptRemoteClient.savedept(newmap);
        return  map;
    }

    @GetMapping("/purchase4")
    public Map getlist4(){
    Map map=new HashMap<>();
    map.put("id",41);
    String dept=  deptRemoteClient.SAVE(new Dept(12,"dsa"));
        map.put("yesorno",dept);

        return  map;
    }

    @GetMapping("/purchase5")
    public int getlist5(){
        Dept dept=deptRemoteClient.querydept(10);
        return  1;
    }



}
